// pages/member/person.js
Page({
  data: {
    nickName: '555',
    userInfoAvatar: 'https://m.360buyimg.com/babel/jfs/t20812/117/2242113312/100592/da1d29e8/5b4d5685Nccbfff39.jpg',
    sex: '',
    province: '',
    city: '',
    screenWidth: 0,
    screenHeight: 0,
    imgwidth: 0,
    imgheight: 0,
    imgwidth2: 0,
    imgheight2: 0,
  },
  imageLoad: function (e) {
    var _this = this;
    var $width = e.detail.width,    //获取图片真实宽度  
      $height = e.detail.height,
      ratio = 1;   //图片的真实宽高比例  
    var viewHeight = 110,           //设置图片显示宽度，  
      viewWidth = 110 / ratio;    //计算的高度值     
    this.setData({
      imgwidth: viewWidth,
      imgheight: viewHeight
    })
  },
  Loadtwo: function (e) {
    var _this = this;
    var $width = e.detail.width,    //获取图片真实宽度  
      $height = e.detail.height,
      ratio = 1;   //图片的真实宽高比例  
    var viewHeight2 = 50,           //设置图片显示宽度，  
      viewWidth2 = 50 / ratio;    //计算的高度值     
    this.setData({
      imgwidth2: viewWidth2,
      imgheight2: viewHeight2
    })
  },
  onLoad: function () {
    var that = this;
    wx.getUserInfo({
      success: function (res) {
        // success  
        that.setData({
          nickName: res.userInfo.nickName,
          userInfoAvatar: res.userInfo.avatarUrl,
          province: res.userInfo.province,
          city: res.userInfo.city
        })
        switch (res.userInfo.gender) {
          case 0:
            that.setData({
              sex: '未知'
            })
            break;
          case 1:
            that.setData({
              sex: '男'
            })
            break;
          case 2:
            that.setData({
              sex: '女'
            })
            break;
        }
      },
      fail: function () {
        // fail  
        console.log("获取失败！")
      },
      complete: function () {
        // complete  
        console.log("获取用户信息完成！")
      }
    })
  },
  toOrder: function () {
    wx.navigateTo({
      url: "/pages/home-page/order"
    })
  }
})